
function toUpperCase(target: string): string {
  return String.prototype.toUpperCase.call(target);
}

function toLowerCase(target: string): string {
  return String.prototype.toLowerCase.call(target);
}

// // Hungarian strUserName
// ['str', 'User', 'Name'].join('')
// // Camel userName
// ['user', 'Name'].join('')
// // Pascal UserName
// ['User', 'Name'].join('')
// // Snake user_name
// ['user', 'name'].join('_')

export function HungarianToCamel(target: string) {
  const [, ...list] = target.split(/(?=[A-Z])/g);
  list[0] = toLowerCase(list[0]);
  return list.join('');
}
export function HungarianToPascal(target: string) {
  const [, ...list] = target.split(/(?=[A-Z])/g);
  return list.join('');
}
export function HungarianToSnake(target: string) {
  const [, ...list] = target.split(/(?=[A-Z])/g);
  return list.map(toLowerCase).join('_');
}


export function CamelToPascal(target: string): string {
   const list = target.split(/(?=[A-Z])/g);
   return list.map((item) => item.replace(/\b\w/g,($0) => $0.toUpperCase())).join('');
}
export function CamelToSnake(target: string): string {
   const list = target.split(/(?=[A-Z])/g);
   return list.map((item) => item.replace(/\b\w/g,($0) => $0.toLowerCase())).join('_');
}


export function PascalToCamel(target: string): string {
   const list = target.split(/(?=[A-Z])/g);
   list[0]=list[0].replace(/\b\w/g,($0) => $0.toLowerCase())
   return list.join('');
}
export function PascalToSnake(target: string): string {
   const list = target.split(/(?=[A-Z])/g);
   return list.map(toLowerCase).join('_');
}

export function SnakeToCamel(target: string): string  {
  const list = target.split(/\_/g);
  return list.map((item,index) => index === 0 ? item : item.replace(/\b\w/g,($0) => $0.toUpperCase())).join('');
}
export function SnakeToPascal(target: string): string {
  const list = target.split(/\_/g);
  return list.map(item => item.replace(/\b\w/g,($0) => $0.toUpperCase())).join('');
}